package com.ce.common.db.dump;

import java.util.List;

import com.ce.common.db.base.DataObject;

/**
 * 执行mysql导出命令的具体类
 * @author yangenxiong
 *
 */
public class DumpContext {
	
	private DumpCommand dump;
	
	public DumpContext() {
		
	}
	
	public DumpContext(DumpCommand dump) {
		this.dump = dump;
	}
	
	public void setDumpCommand(DumpCommand dump) {
		this.dump = dump;
	}
	
	public DumpCommand getDumpCommand() {
		return this.dump;
	}

	/**
	 * 执行命令
	 * @author yangenxiong
	 * @param tableNames 需要导出的表的对象集合
	 * @param outputFileName 导出的sql文件名
	 */
	public boolean executeCommand(List<DataObject> tableNames, String outputFileName) {
		try {
			java.lang.Runtime.getRuntime().exec(dump.getDumpCommand(tableNames, outputFileName));
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		} 
	}
}
